package com.woniuxy01;

/**
 * @author 作者
 * @create 2025-09-10 9:33
 */
public class Test04 {
    public static void main(String[] args) {
        String source="ajavasbajavacefjavagxjavafeg";
        String target="java";
        System.out.println(countSubString(source, target));
    }

    public static int countSubString(String source,String target){
        int length=target.length();
        int count=0,index=-1,startIndex=0;
        while(true){
            index = source.indexOf(target, startIndex);
            if(index==-1){
                break;
            }
            count++;
            startIndex=index+target.length();
        }
        return count;
    }

    private static void test02() {
        String str = "aC1bAcB3d";
        int small = 0, big = 0, num = 0;
        char[] chars = str.toCharArray();
        for (char c : chars) {
//            if(Character.isDigit(c))
            if(c>='0' && c<='9') {
                num++;
            }else if(c>='A' && c<='Z') {
                big++;
            }else if(c>='a' && c<='z') {
                small++;
            }
        }
        System.out.println("small:"+small+" big:"+big+" num:"+num);
    }

    private static void test01() {
        String str = "abcdef";
        str = reverse(str);
        System.out.println(str);
    }

    private static String reverse(String str) {
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length / 2; i++) {
            char temp = chars[i];
            chars[i] = chars[chars.length - 1 - i];
            chars[chars.length - 1 - i] = temp;
        }
        str = new String(chars);
        return str;
    }


}
